package com.tlias.jwt.service;



import com.tlias.mapper.EmpMapper;
import com.tlias.pojo.Emp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @title: UserService
 * @Author gjt
 * @Date: 2020-12-21
 * @Description：
 */
@Service
public class JwtEmpService {
    @Autowired
    EmpMapper empMapper;


    public Emp getUser(String username, String password){
        Emp emp = empMapper.selectEmpByPwd(username, password);
        if (emp.getUsername().equals(username) && emp.getPassword().equals(password)){
            Emp rEmp=new Emp();
            rEmp.setId(emp.getId());
            rEmp.setUsername(emp.getUsername());
            rEmp.setPassword(emp.getPassword());
            return rEmp;
        }
        else{
            return null;
        }
    }

    public Emp getUser(String username){
        Emp emp = empMapper.selectEmpByPwd(username,null);
        if (emp.getUsername().equals(username)){
            Emp rEmp=new Emp();
            rEmp.setId(emp.getId());
            rEmp.setUsername(emp.getUsername());
            rEmp.setPassword(emp.getPassword());
            return rEmp;
        }
        else{
            return null;
        }
    }
}
